# -*- coding: utf-8 -*-
"""
Created on Sun Jan 17 16:43:21 2021

@author: PC
"""

class Grade():
    def __init__(self,name,grade,n):
        self.name = name
        self.grade = float(grade)
        self.n = int(n)

    def judge(self):
        
        if self.grade >= 90:
            self.gpa = float(4.0)
        
        elif self.grade >= 85:
            self.gpa = float(3.7)
        
        elif self.grade >= 82:
            self.gpa = float(3.3)
        
        elif self.grade >= 78:
            self.gpa = float(3.0)
            
        elif self.grade >= 75:
            self.gpa = float(2.7)
            
        elif self.grade >= 72:
            self.gpa = float(2.3)
        
        elif self.grade >= 68:
            self.gpa = float(2.0)
        
        elif self.grade >= 64:
            self.gpa = float(1.5)
            
        elif self.grade >= 60:
            self.gpa = float(1.3)
        
        else:
            self.gpa = float(0.0)
            
        nlist.append(self.n)
        gpalist.append(self.n*self.gpa)
        
        print('您的%s学科，绩点为%.1f'%(self.name,self.gpa))
            
        return nlist and gpalist
            
nlist = []  

gpalist = []

print('这是一个计算绩点的小程序，在学科名称输入q来结束')

while True:

    name0 = input('请输入学科名称:')


    if name0 !="q":
        
        grade0 = input("请输入考试成绩：") 

        n0 = input("请输入学分：")
    
        name0 = Grade(name0,grade0,n0)
    
        name0.judge()
    
    else:
        gpa = sum(gpalist)
        n = sum(nlist)
        totalgpa = gpa/n
        print('您一共输入了%s门学科'%(len(nlist)))
        print("您的总GPA是%.4f"%(totalgpa))
        break